package com.crazy.crazybusinessservice.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.crazy.crazybusinessservice.VO.TransactionDTO;
import com.crazy.crazymodel.model.entity.Transaction;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

@Mapper
public interface TransactionMapper  extends BaseMapper<TransactionDTO> {

    @Select("select transactionId,transactionType,cancelTime from transaction where status = 0")
    List<Transaction> selectTranscationIdByStatus();

    @Select("select * from transaction where status = 0")
    List<Transaction> selectTranscationByStatus();

    @Update("update transaction set status = 1 where transactionId=${id}")
    void updateStatusById(@Param("id") long id);


    List<TransactionDTO> findTransactionsByFuzzyCriteria(
            @Param("customerName")String customerName,
            @Param("customerType")int customerType,
            @Param("customerID")String customerID,
            @Param("productId")int productId,
            @Param("productName")String productName,
            @Param("status")int status,
            @Param("transactionType")int transactionType,
            @Param("begin") Date begin,
            @Param("end")Date end,
            @Param("current")Long current,
            @Param("limit")Long limit
    );


}
